package com.example.controller;

import com.example.pojo.Result;
import com.example.service.VisitorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/visitor")
public class VisitorController {

    @Autowired
    private VisitorService visitorService;

    // 路径中的{id}对应景点详情表的ID
    @GetMapping("/{id}")
    public Result<Result.ResponseData<Void>> addVisitor(@PathVariable Integer id) {
        // 记录访客（累加该景点的访客量）
        visitorService.addVisitorRecord(id);

        // 构建响应：code=1000，msg=success，data=null
        Result.ResponseData<Void> responseData = new Result.ResponseData<>();
        responseData.setCode(1000);
        responseData.setMsg("success");
        responseData.setData(null);

        return Result.success(responseData);
    }
}